package com.wkq.move.module.tv.frame.presenter

import android.util.Log
import com.wkq.base.frame.mosby.MvpBasePresenter
import com.wkq.move.module.tv.frame.view.UsTvShowView
import com.wkq.net.model.UsTvDetailInfo
import com.wkq.net.model.UsTvPlayInfo
import com.wkq.net.net.UsTvShowDataCallBack
import com.wkq.net.net.UsTvShowHtmlUtil

/**
 *
 * 作者:吴奎庆
 *
 * 时间:2020/5/18
 *
 * 用途:
 */


class UsTvShowPresenter : MvpBasePresenter<UsTvShowView>() {
    fun initData(tvPath: String?) {
        UsTvShowHtmlUtil.getTvDetail(tvPath, object : UsTvShowDataCallBack<UsTvDetailInfo> {
            override fun onFail(message: String?) {
                if(view!=null) { view.showMessage(message) }
            }

            override fun onSuccess(info: UsTvDetailInfo?) {
              ifViewAttached { view -> view.showView(info) }
            }

            override fun onLoading() {
            }
        })
    }

    fun getPlayPath(tvPath: String?) {
        UsTvShowHtmlUtil.getPlayPath(tvPath, object : UsTvShowDataCallBack<UsTvPlayInfo> {
            override fun onFail(message: String?) {

                Log.e("测试:", message)
            }

            override fun onSuccess(info: UsTvPlayInfo?) {
                ifViewAttached { view -> view.playTv(info) }
            }

            override fun onLoading() {
                TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
            }
        })
    }
}